home *** CD-ROM | disk | FTP | other *** search
- /*
- QuickCode V1.5
-
- A Mathscript ButtonBar, allowing rapid access to your 10 most
- used formula elements.
-
- This is the ARexx layer for QuickCode.gc, and is designed
- to be run via this GUI script, NOT directly by the user!
-
- Chris Coulson
-
- 28.12.96
- 05.01.97
- 09.01.97 - Version 1.0
- Code lookup from env:.qcprefs, and insertion into Mathscript.
- But, we're getting spurious errors on the GETARG(), looks like
- WAITPKT() is exiting when it shouldn't :-( I've put in a
- fix, but I'd rather WAITPKT() did it internally...
- 12.01.97 - Fixed "therefore" insertion problem.
- 13.01.97 - Version 1.1
- Now tests for the presence of the Mathscript Rexx port before
- sending any commands. This allows the user to play with
- QuickCode without needing Mathscript running, and more
- importantly it also removes the error message you get if you
- quit Mathscript before QuickCode
- 14.01.97 - Oops, a somewhat overenthusiastic bit of optimisation removed
- the SELECT...END from the WHEN tree in SendMSCode(). Sorry
- about that!
- 17.01.97 - Somehow I managed to miss the fact that the Clear button was no
- longer working... fixed!
- 18.01.97 - Version 1.2
- Added MxN matrix
- 21.01.97 - Version 1.3
- Added new codes from Mathscript 3.1
- 25.01.97 - Version 1.4
- Finally seen Simon's new bug for myself, and I think I've fixed it...
- 28.01.97 - Version 1.5
- Let's try that again, shall we... NOW I think I've fixed the bug :-)
- */
-
- IF ~SHOW('L','rexxsupport.library') THEN
- DO
- IF ~ADDLIB('rexxsupport.library',0,-30,0) THEN
- DO
- SAY 'REXXSupport.library not found!'
- EXIT 10
-
- END
- END
-
- port_ok = OPENPORT('quickcode')
- IF port_ok THEN
- DO
- CALL GetCmd
- DO FOREVER
-
- /*
- OK, we'll accept that sometimes WAITPKT() exits even if there
- isn't a packet arrived. In that case, we must check the
- return value, which will always reflect the truth regarding
- packet arrival. Why WAITPKT() doesn't do this itself is just
- another of those computing mysteries...
- */
-
- isthereapacket = FALSE
- DO UNTIL isthereapacket
- isthereapacket = WAITPKT('quickcode')
- END
- packet = GETPKT('quickcode')
- function = GETARG(packet)
- function = UPPER(function)
- REPLY(packet,0)
- SELECT
- WHEN function = 'EXIT' THEN LEAVE
- WHEN function = 'PREFS' THEN CALL GetCmd
- WHEN LEFT(function,1) = 'B' THEN
- DO
- IF showlist('P','MATHSCRIPT.1') THEN
- DO
- SendMSCode()
- END
- END
- END
- END
-
- /*
-
- Time to close up shop for the evening...
- */
-
- CLOSEPORT('quickcode')
- END
- EXIT
-
-
-
- SendMSCode:
- ADDRESS MATHSCRIPT.1
- SELECT
- WHEN function = 'B0' THEN
- DO
- IF cmd0 ~= "blank" THEN "insertcode " cmd0
- END
- WHEN function = 'B1' THEN
- DO
- IF cmd1 ~= "blank" THEN "insertcode " cmd1
- END
- WHEN function = 'B2' THEN
- DO
- IF cmd2 ~= "blank" THEN "insertcode " cmd2
- END
- WHEN function = 'B3' THEN
- DO
- IF cmd3 ~= "blank" THEN "insertcode " cmd3
- END
- WHEN function = 'B4' THEN
- DO
- IF cmd4 ~= "blank" THEN "insertcode " cmd4
- END
- WHEN function = 'B5' THEN
- DO
- IF cmd5 ~= "blank" THEN "insertcode " cmd5
- END
- WHEN function = 'B6' THEN
- DO
- IF cmd6 ~= "blank" THEN "insertcode " cmd6
- END
- WHEN function = 'B7' THEN
- DO
- IF cmd7 ~= "blank" THEN "insertcode " cmd7
- END
- WHEN function = 'B8' THEN
- DO
- IF cmd8 ~= "blank" THEN "insertcode " cmd8
- END
- WHEN function = 'B9' THEN
- DO
- IF cmd9 ~= "blank" THEN "insertcode " cmd9
- END
- WHEN SUBWORD(function,1,1) = 'BX' THEN
- DO
- columns = SUBWORD(function,2,1)
- rows = SUBWORD(function,3,1)
- elements = columns * rows
- cmd = "\mx"||rows||columns
- DO loop=1 TO elements
- cmd = cmd||"[]"
- END
- "insertcode " cmd
- END
- WHEN function = 'BCLR' THEN
- DO
- clear
- END
- END
- RETURN 0
-
-
- GetCmd:
-
- /*
- Although envvar should be present at all times, it seems that under certain
- circumstances it can't be opened, causing an error on the READLN() line.
- So we'll try opening it up to 10 times before giving up and returning a
- blank prefs string.
- */
-
- DO
- envopen = OPEN("envvar","env:.qcprefs",READ)
- UNTIL envopen
- envstr = READLN("envvar")
- CLOSE("envvar")
-
- cmd0 = LUCmd(WORD(envstr,1))
- cmd1 = LUCmd(WORD(envstr,2))
- cmd2 = LUCmd(WORD(envstr,3))
- cmd3 = LUCmd(WORD(envstr,4))
- cmd4 = LUCmd(WORD(envstr,5))
- cmd5 = LUCmd(WORD(envstr,6))
- cmd6 = LUCmd(WORD(envstr,7))
- cmd7 = LUCmd(WORD(envstr,8))
- cmd8 = LUCmd(WORD(envstr,9))
- cmd9 = LUCmd(WORD(envstr,10))
- RETURN
-
-
- LUCmd: PROCEDURE
- parse arg cmdstr
- dirsep = POS('/',cmdstr)
- IF dirsep = 0 THEN
- DO
- cmd = "blank"
- END
- ELSE
- DO
- bank = LEFT(cmdstr,dirsep-1)
- cmdid = RIGHT(cmdstr,LENGTH(cmdstr)-dirsep)
- SELECT
- WHEN bank = '1' THEN cmd = LUBank1(cmdid)
- WHEN bank = '2' THEN cmd = LUBank2(cmdid)
- WHEN bank = '3' THEN cmd = LUBank3(cmdid)
- WHEN bank = '4' THEN cmd = LUBank4(cmdid)
- WHEN bank = '5' THEN cmd = LUBank5(cmdid)
- WHEN bank = '6' THEN cmd = LUBank6(cmdid)
- WHEN bank = '7' THEN cmd = LUBank7(cmdid)
- WHEN bank = '8' THEN cmd = LUBank8(cmdid)
- WHEN bank = '9' THEN cmd = LUBank9(cmdid)
- WHEN bank = '10' THEN cmd = LUBank10(cmdid)
- WHEN bank = '11' THEN cmd = LUBank11(cmdid)
- WHEN bank = '12' THEN cmd = LUBank12(cmdid)
- WHEN bank = '13' THEN cmd = LUBank13(cmdid)
- WHEN bank = '14' THEN cmd = LUBank14(cmdid)
- END
- END
- RETURN cmd
-
-
- LUBank1: PROCEDURE
- parse arg cmdid
- SELECT
- WHEN cmdid = '1' THEN cmd = "\sy+"
- WHEN cmdid = '2' THEN cmd = "\sy-"
- WHEN cmdid = '3' THEN cmd = "\sy±"
- WHEN cmdid = '4' THEN cmd = "\sy×"
- WHEN cmdid = '5' THEN cmd = "\sy´"
- WHEN cmdid = '6' THEN cmd = "\sy¸"
- WHEN cmdid = '7' THEN cmd = "\syÄ"
- WHEN cmdid = '8' THEN cmd = "\syÅ"
- WHEN cmdid = '9' THEN cmd = "\sy·"
- END
- RETURN cmd
-
-
- LUBank2: PROCEDURE
- parse arg cmdid
- SELECT
- WHEN cmdid = '1' THEN cmd = "\sy«"
- WHEN cmdid = '2' THEN cmd = "\syÛ"
- WHEN cmdid = '3' THEN cmd = "\sy¬"
- WHEN cmdid = '4' THEN cmd = "\syÜ"
- WHEN cmdid = '5' THEN cmd = "\sy"
- WHEN cmdid = '6' THEN cmd = "\syÝ"
- WHEN cmdid = '7' THEN cmd = "\sy®"
- WHEN cmdid = '8' THEN cmd = "\syÞ"
- WHEN cmdid = '9' THEN cmd = "\sy¯"
- WHEN cmdid = '10' THEN cmd = "\syß"
- END
- RETURN cmd
-
- LUBank3: PROCEDURE
- parse arg cmdid
- SELECT
- WHEN cmdid = '1' THEN cmd = "\sy\"
- WHEN cmdid = '2' THEN cmd = "\sy'"
- WHEN cmdid = '3' THEN cmd = "\sy$"
- WHEN cmdid = '4' THEN cmd = "\sy"""
- WHEN cmdid = '5' THEN cmd = "\syÙ"
- WHEN cmdid = '6' THEN cmd = "\syÚ"
- WHEN cmdid = '7' THEN cmd = "\syØ"
- END
- RETURN cmd
-
- LUBank4: PROCEDURE
- parse arg cmdid
- SELECT
- WHEN cmdid = '1' THEN cmd = "\l([]\r)"
- WHEN cmdid = '2' THEN cmd = "\l([]"
- WHEN cmdid = '3' THEN cmd = "[]\r)"
- WHEN cmdid = '4' THEN cmd = "\l{[]\r}"
- WHEN cmdid = '5' THEN cmd = "\l{[]"
- WHEN cmdid = '6' THEN cmd = "[]\r}"
- WHEN cmdid = '7' THEN cmd = "\l|[]\r|"
- WHEN cmdid = '8' THEN cmd = "\l|[]"
- WHEN cmdid = '9' THEN cmd = "[]\r|"
- WHEN cmdid = '10' THEN cmd = "\l<[]\r>"
- WHEN cmdid = '11' THEN cmd = "\l<[]"
- WHEN cmdid = '12' THEN cmd = "[]\r>"
- WHEN cmdid = '13' THEN cmd = "\l[[]\r]"
- WHEN cmdid = '14' THEN cmd = "\l[[]"
- WHEN cmdid = '15' THEN cmd = "[]\r]"
- WHEN cmdid = '16' THEN cmd = "\l][]\r["
- WHEN cmdid = '17' THEN cmd = "\l][]"
- WHEN cmdid = '18' THEN cmd = "[]\r["
- WHEN cmdid = '19' THEN cmd = "\l[[]\r["
- WHEN cmdid = '20' THEN cmd = "\l][]\r]"
- END
- RETURN cmd
-
- LUBank5: PROCEDURE
- parse arg cmdid
- SELECT
- WHEN cmdid = '1' THEN cmd = "\syÕ"
- WHEN cmdid = '2' THEN cmd = "\syÕ\ud[][]"
- WHEN cmdid = '3' THEN cmd = "\syå"
- WHEN cmdid = '4' THEN cmd = "\syå\ud[][]"
- WHEN cmdid = '5' THEN cmd = "\syò"
- WHEN cmdid = '6' THEN cmd = "\syò\ud[][]"
- END
- RETURN cmd
-
- LUBank6: PROCEDURE
- parse arg cmdid
- SELECT
- WHEN cmdid = '1' THEN cmd = "\gra"
- WHEN cmdid = '2' THEN cmd = "\grb"
- WHEN cmdid = '3' THEN cmd = "\grg"
- WHEN cmdid = '4' THEN cmd = "\grd"
- WHEN cmdid = '5' THEN cmd = "\gre"
- WHEN cmdid = '6' THEN cmd = "\grz"
- WHEN cmdid = '7' THEN cmd = "\grh"
- WHEN cmdid = '8' THEN cmd = "\grq"
- WHEN cmdid = '9' THEN cmd = "\grJ"
- WHEN cmdid = '10' THEN cmd = "\gri"
- WHEN cmdid = '11' THEN cmd = "\grk"
- WHEN cmdid = '12' THEN cmd = "\grl"
- WHEN cmdid = '13' THEN cmd = "\grm"
- WHEN cmdid = '14' THEN cmd = "\grn"
- WHEN cmdid = '15' THEN cmd = "\grx"
- WHEN cmdid = '16' THEN cmd = "\gro"
- WHEN cmdid = '17' THEN cmd = "\grp"
- WHEN cmdid = '18' THEN cmd = "\grr"
- WHEN cmdid = '19' THEN cmd = "\grs"
- WHEN cmdid = '20' THEN cmd = "\grV"
- WHEN cmdid = '21' THEN cmd = "\grt"
- WHEN cmdid = '22' THEN cmd = "\gru"
- WHEN cmdid = '23' THEN cmd = "\grf"
- WHEN cmdid = '24' THEN cmd = "\grj"
- WHEN cmdid = '25' THEN cmd = "\grc"
- WHEN cmdid = '26' THEN cmd = "\gry"
- WHEN cmdid = '27' THEN cmd = "\grw"
- WHEN cmdid = '28' THEN cmd = "\grv"
- END
- RETURN cmd
-
- LUBank7: PROCEDURE
- parse arg cmdid
- SELECT
- WHEN cmdid = '1' THEN cmd = "\grA"
- WHEN cmdid = '2' THEN cmd = "\grB"
- WHEN cmdid = '3' THEN cmd = "\grG"
- WHEN cmdid = '4' THEN cmd = "\grD"
- WHEN cmdid = '5' THEN cmd = "\grE"
- WHEN cmdid = '6' THEN cmd = "\grZ"
- WHEN cmdid = '7' THEN cmd = "\grH"
- WHEN cmdid = '8' THEN cmd = "\grQ"
- WHEN cmdid = '9' THEN cmd = "\grI"
- WHEN cmdid = '10' THEN cmd = "\grK"
- WHEN cmdid = '11' THEN cmd = "\grL"
- WHEN cmdid = '12' THEN cmd = "\grM"
- WHEN cmdid = '13' THEN cmd = "\grN"
- WHEN cmdid = '14' THEN cmd = "\grX"
- WHEN cmdid = '15' THEN cmd = "\grO"
- WHEN cmdid = '16' THEN cmd = "\grP"
- WHEN cmdid = '17' THEN cmd = "\grR"
- WHEN cmdid = '18' THEN cmd = "\grS"
- WHEN cmdid = '19' THEN cmd = "\grT"
- WHEN cmdid = '20' THEN cmd = "\grU"
- WHEN cmdid = '21' THEN cmd = "\grF"
- WHEN cmdid = '22' THEN cmd = "\grC"
- WHEN cmdid = '23' THEN cmd = "\grY"
- WHEN cmdid = '24' THEN cmd = "\grW"
- END
- RETURN cmd
-
- LUBank8: PROCEDURE
- parse arg cmdid
- SELECT
- WHEN cmdid = '1' THEN cmd = "\sy="
- WHEN cmdid = '2' THEN cmd = "\sy»"
- WHEN cmdid = '3' THEN cmd = "\sy¹"
- WHEN cmdid = '4' THEN cmd = "\syº"
- WHEN cmdid = '5' THEN cmd = "\sy@"
- WHEN cmdid = '6' THEN cmd = "\syµ"
- WHEN cmdid = '7' THEN cmd = "\sy<"
- WHEN cmdid = '8' THEN cmd = "\sy£"
- WHEN cmdid = '9' THEN cmd = "\sy>"
- WHEN cmdid = '10' THEN cmd = "\sy³"
- END
- RETURN cmd
-
- LUBank9: PROCEDURE
- parse arg cmdid
- SELECT
- WHEN cmdid = '1' THEN cmd = "\syÇ"
- WHEN cmdid = '2' THEN cmd = "\syÈ"
- WHEN cmdid = '3' THEN cmd = "\syÉ"
- WHEN cmdid = '4' THEN cmd = "\syÊ"
- WHEN cmdid = '5' THEN cmd = "\syÌ"
- WHEN cmdid = '6' THEN cmd = "\syÍ"
- WHEN cmdid = '7' THEN cmd = "\syÎ"
- WHEN cmdid = '8' THEN cmd = "\syÏ"
- WHEN cmdid = '9' THEN cmd = "\syË"
- WHEN cmdid = '10' THEN cmd = "\syÆ"
- END
- RETURN cmd
-
- LUBank10: PROCEDURE
- parse arg cmdid
- SELECT
- WHEN cmdid = '1' THEN cmd = "\sy¥"
- WHEN cmdid = '2' THEN cmd = "\syÐ"
- WHEN cmdid = '3' THEN cmd = "\sy¶"
- WHEN cmdid = '4' THEN cmd = "\syÑ"
- WHEN cmdid = '5' THEN cmd = "\syÁ"
- WHEN cmdid = '6' THEN cmd = "\syÂ"
- WHEN cmdid = '7' THEN cmd = "\syÀ"
- WHEN cmdid = '8' THEN cmd = "\syÃ"
- WHEN cmdid = '9' THEN cmd = "\syà"
- WHEN cmdid = '10' THEN cmd = "\^"
- WHEN cmdid = '11' THEN cmd = "\sy°"
- END
- RETURN cmd
-
- LUBank11: PROCEDURE
- parse arg cmdid
- SELECT
- WHEN cmdid = '1' THEN cmd = "^[]"
- WHEN cmdid = '2' THEN cmd = "_[]"
- WHEN cmdid = '3' THEN cmd = "^_[][]"
- WHEN cmdid = '4' THEN cmd = "[]\up[]"
- WHEN cmdid = '5' THEN cmd = "[]\dn[]"
- WHEN cmdid = '6' THEN cmd = "[]\ud[][]"
- END
- RETURN cmd
-
- LUBank12: PROCEDURE
- parse arg cmdid
- SELECT
- WHEN cmdid = '1' THEN cmd = "\sqrt[]"
- WHEN cmdid = '2' THEN cmd = "\rt[][]"
- WHEN cmdid = '3' THEN cmd = "[]/[]"
- END
- RETURN cmd
-
- LUBank13: PROCEDURE
- parse arg cmdid
- SELECT
- WHEN cmdid = '1' THEN cmd = "\rvec[]"
- WHEN cmdid = '2' THEN cmd = "\lvec[]"
- WHEN cmdid = '3' THEN cmd = "\bvec[]"
- WHEN cmdid = '4' THEN cmd = "\ul[]"
- WHEN cmdid = '5' THEN cmd = "\ol[]"
- WHEN cmdid = '6' THEN cmd = "\not[]"
- WHEN cmdid = '7' THEN cmd = "\aacute[]"
- WHEN cmdid = '8' THEN cmd = "\agrave[]"
- WHEN cmdid = '9' THEN cmd = "\ahat[]"
- WHEN cmdid = '10' THEN cmd = "\acheck[]"
- WHEN cmdid = '11' THEN cmd = "\abreve[]"
- WHEN cmdid = '12' THEN cmd = "\atilde[]"
- WHEN cmdid = '13' THEN cmd = "\dx1"
- WHEN cmdid = '14' THEN cmd = "\dx2"
- WHEN cmdid = '15' THEN cmd = "\dx3"
- WHEN cmdid = '16' THEN cmd = "\dt1[]"
- WHEN cmdid = '17' THEN cmd = "\dt2[]"
- END
- RETURN cmd
-
- LUBank14: PROCEDURE
- parse arg cmdid
- SELECT
- WHEN cmdid = '1' THEN cmd = "\mx21[][]"
- WHEN cmdid = '2' THEN cmd = "\mx22[][][][]"
- WHEN cmdid = '3' THEN cmd = "\mx23[][][][][][]"
- WHEN cmdid = '4' THEN cmd = "\mx24[][][][][][][][]"
- WHEN cmdid = '5' THEN cmd = "\mx31[][][]"
- WHEN cmdid = '6' THEN cmd = "\mx32[][][][][][]"
- WHEN cmdid = '7' THEN cmd = "\mx33[][][][][][][][][]"
- WHEN cmdid = '8' THEN cmd = "\mx34[][][][][][][][][][][][]"
- WHEN cmdid = '9' THEN cmd = "\mx41[][][][]"
- WHEN cmdid = '10' THEN cmd = "\mx42[][][][][][][][]"
- WHEN cmdid = '11' THEN cmd = "\mx43[][][][][][][][][][][][]"
- WHEN cmdid = '12' THEN cmd = "\mx44[][][][][][][][][][][][][][][][]"
- WHEN cmdid = '13' THEN cmd = ""
- END
- RETURN cmd
-